package com.jsbs.iam.user.controller;

import com.alibaba.fastjson.JSON;
import com.jsbs.iam.common.core.dto.Result;
import com.jsbs.iam.user.mapper.IamButtonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author junwc
 * @Date 2022/12/8
 * @Version 1.0
 */
@RestController
@RequestMapping("/iam/user")
public class IamButtonInfoApiController extends BaseController{
    private static final Logger logger = LoggerFactory.getLogger(IamButtonInfoApiController.class);

    @Autowired
    private IamButtonMapper iamButtonMapper;

    /**
     * 功能描述：根据按钮编码获取按钮数据
     * @param buttonCodeList
     * @return
     */
    @PostMapping("/getButtonInfoList")
    public Result getButtonInfoList(@RequestBody List<String> buttonCodeList) {
        try {
            logger.info("Route==>IamButtonInfoApiController method=getButtonInfoList 根据按钮编码查询按钮信息，入参:{}", JSON.toJSONString(buttonCodeList));
            return Result.success(iamButtonMapper.queryByButtonCode(buttonCodeList));
        }catch (Exception e){
            logger.error("Route==>IamButtonInfoApiController method=getButtonInfoList 根据按钮编码查询按钮信息异常：{}，入参:{}", e.getMessage(), JSON.toJSONString(buttonCodeList));
            return handleException(e);
        }
    }


}
